<template>
  <div>
    <el-table :data="tableData" style="width: 100%" @row-click="handleTableRow">
      <el-table-column type="index" width="180" label="序号" />
      <el-table-column prop="title" label="动态标题" width="530" />
      <el-table-column prop="publishDatetime" label="发布时间" />
    </el-table>

    <div class="block">
      <span class="demonstration">调整每页显示条数</span>
      <el-pagination
        @size-change="findData"
        @current-change="findData"
        v-model:current-page="pageNum"
        :page-sizes="[3, 5, 7, 9]"
        v-model:page-size="pageSize"
        layout="sizes, prev, pager, next"
        :total="total"
      >
      
      </el-pagination>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { list  } from "../api/pingtai";

const pageNum = ref(1);
const pageSize = ref(3);
const total = ref();
const tableData = ref([]);

//=======================分页列表====================
const findData = async () => {
  const { code, data, message } = await list(pageNum.value, pageSize.value);
  tableData.value = data.rows;
  total.value = data.total;
};

const handleTableRow = async () => {
  const that = this;
  that.$router.push(`/pingtaiDetails?id=${row.id}`)
};

onMounted(() => {
  findData();
});
</script>

<style>
</style>